<template>
  <div class="UserMemberAdd addButton">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>学生信息管理</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/studentInfo/member/list' }">学生信息列表</el-breadcrumb-item>
      <el-breadcrumb-item>学生信息修改</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="form">
      <div class="form">
        <el-form ref="form" :model="form" label-width="100px" size="small">
          <el-form-item label="学号">
            {{userNumber}}
            <!--<el-input v-model="userNumber" placeholder="请输入用户手机号" disabled size="small"-->
            <!--          style="width:230px"></el-input>-->
          </el-form-item>
          <el-form-item label="姓名">
            <el-input v-model="form.name" placeholder="请输入用户姓名" size="small" style="width:230px"></el-input>
          </el-form-item>
          <el-form-item label="手机号">
            <el-input v-model="form.phone" placeholder="请输入用户手机号" size="small" style="width:230px"></el-input>
          </el-form-item>
          <el-form-item label="性别" prop="sex">
            <el-radio-group v-model="form.sex">
              <el-radio :label="1">男</el-radio>
              <el-radio :label="2">女</el-radio>
            </el-radio-group>
          </el-form-item>
          <!--<el-form-item label="班级">-->
          <!--  <el-select v-model="form.class" placeholder="选择班级" style="width:230px">-->
          <!--    <el-option-->
          <!--      v-for="item in classList"-->
          <!--      :key="item.id"-->
          <!--      :label="item.name"-->
          <!--      :value="item.id">-->
          <!--    </el-option>-->
          <!--  </el-select>-->
          <!--</el-form-item>-->
          <el-form-item label="身份证号">
            <el-input v-model="form.identityCard" placeholder="" size="small" style="width:230px"></el-input>
          </el-form-item>
          <el-form-item label="现居住地">
            <el-input v-model="form.address" placeholder="" size="small" style="width:230px"></el-input>
          </el-form-item>
          <el-form-item label="身份证所在地">
            <el-input v-model="form.idEntityCardAddress" placeholder="" size="small" style="width:230px"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button style="background:#fb9654;color:#fff" @click="onSubmit">立即提交</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>

</template>
<script>
export default {
  data() {
    return {
      classList: [],
      userNumber:"", //学号
      form: {
        "id": "",   //用户id
        "name": "",   //同学姓名,
        "phone": "",   //用户手机号
        "identity": "",   //用户身份  0:管理员 / 1:学生 /2:老师
        "roleId": "",   //角色权限id
        "identityCard": "",   //用户身份证号
        "idEntityCardAddress": "",   ////用户身份证地址
        "address": "",   ////现居住地址
        "admissionTime": "",   //入学时间
        "sex": "",   //1/2 男/女
      }
    };
  },
  mounted() {
    this.form.id = this.$route.query.id;
    this.userNumber = this.$route.query.userNumber
    this.getUserDetail();
    this.getClassList();
  },
  methods: {
    getUserDetail() {
      this.$api.studentInfo.getUserDetail({ id: this.form.id })
        .then((res) => {
          console.log(res);
          this.form = res.data;
          this.form.idEntityCardAddress = res.data.identityCardAddress;
        });
    },
    getClassList() {
      this.$api.education.classList({
        pageNum: 1,
        pageSize: 100
      }).then((res) => {
        if (res.code === 200) {
          console.log(res);
          this.classList = res.data.list;
        }
      });
    },
    //提交添加的数据
    onSubmit() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          let params = {
            "id": this.form.id, //用户id
            "name": this.form.name,
            "phone": this.form.phone, //用户手机号
            "identity": this.form.identity, //用户身份  0:管理员 / 1:学生 /2:老师
            "roleId": this.form.roleId,
            "identityCard": this.form.identityCard, //用户身份证号
            "idEntityCardAddress": this.form.idEntityCardAddress, //用户身份证地址
            "address": this.form.address, //现居住地址
            "admissionTime": this.form.admissionTime, //入学时间
            "sex": this.form.sex //性别 1/2 男/女
          };
          this.$api.studentInfo.userStudentUpdate(params)
            .then((res) => {
              this.$message.success("修改成功");
            });

        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },

};
</script>
<style src="./add.css" scoped>

</style>
